/*
 Copyright 2008 Joseph Nwachukwu and Jason E. Smith. Licensed under the Apache License, Version 2.0 (the "License");
 You may obtain a copy of the License at http:www.apache.org/licenses/LICENSE-2.0
 */
ensure("Carousel/*");

Helix = namespace("controls::Helix", { 
    inherits: 	Carousel,
	
	initialize : function(){
		setInterval(this.render.bind(this), 24)
	},
	
	onmousemove: function(e){},
	
    render: function(){
        for (i = 0; i < this.children.length; i++) {
            var angle = i * (Math.PI * 2) / this.children.length;
			var posX = (Math.sin(this.count * (this.get("baseSpeed") * this.get("speed")) + angle) * this.get("radiusX") + this.get("centerX"));
            var posY = (Math.cos(this.count * (this.get("baseSpeed") * this.get("speed")) + angle) * this.get("radiusY") + this.get("centerY"));
            this.children[i].setStyles({
				position 	: 'relative', 
                left     	: Math.round(posX) + "px",
                top	        : Math.round(posY) + "px",
                width	    : Math.round(posY / 3) + "px",
                "z-index"	: Math.round(posY / 3) + 100
            });
            angle += this.speed;
        }
        this.count++;
		return this.element;
    }
});